{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "7b759a05-9483-4df8-8787-c01a8ddf8f4b",
   "metadata": {},
   "source": [
    "# Random Weight Initialization"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "98b6b513-4095-44e1-9f7d-65a298d01c02",
   "metadata": {},
   "source": [
    "### Without Random Seed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6134dabb-ecae-47cc-9a51-0a08d3acb520",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Parameter containing:\n",
      "tensor([[ 0.1458, -0.5813],\n",
      "        [-0.3033,  0.0979],\n",
      "        [-0.0911, -0.2116]], requires_grad=True)\n"
     ]
    }
   ],
   "source": [
    "import torch \n",
    "\n",
    "\n",
    "layer = torch.nn.Linear(2, 3)\n",
    "print(layer.weight)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "bd12f614-c46a-4c43-a22c-7e45088dcd6a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Parameter containing:\n",
      "tensor([[ 0.1760, -0.6285],\n",
      "        [-0.1398, -0.0959],\n",
      "        [ 0.3127,  0.4303]], requires_grad=True)\n"
     ]
    }
   ],
   "source": [
    "layer = torch.nn.Linear(2, 3)\n",
    "print(layer.weight)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a5a897b2-f3b7-48e9-a23a-adb7b016fd83",
   "metadata": {},
   "source": [
    "### With Random Seed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5c4388d8-f30c-41d8-90ff-1e88547beb87",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Parameter containing:\n",
      "tensor([[-0.2883,  0.0234],\n",
      "        [-0.3512,  0.2667],\n",
      "        [-0.6025,  0.5183]], requires_grad=True)\n"
     ]
    }
   ],
   "source": [
    "torch.manual_seed(123)\n",
    "\n",
    "layer = torch.nn.Linear(2, 3)\n",
    "print(layer.weight)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "26f89be0-1adf-4c3d-b3c3-a8316e7f50d9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Parameter containing:\n",
      "tensor([[-0.2883,  0.0234],\n",
      "        [-0.3512,  0.2667],\n",
      "        [-0.6025,  0.5183]], requires_grad=True)\n"
     ]
    }
   ],
   "source": [
    "torch.manual_seed(123)\n",
    "\n",
    "layer = torch.nn.Linear(2, 3)\n",
    "print(layer.weight)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
